<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增offer流程')" />
    <th:block th:include="include :: select2-css" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-hrOff-add">

            <div class="form-group">
                <label class="col-sm-3 control-label is-required">姓名：</label>
                <div class="col-sm-8">
                    <input name="toOffName" class="form-control" maxlength="10" type="text" required>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label is-required">入职城市：</label>
                <div class="col-sm-4">
                    <select class="form-control m-b" name="city" th:with="type=${@dict.getType('citys')}" required>
                        <option value="">所有</option>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">入职部门：</label>
                <div class="col-sm-8">
                    <select name="deptId" class="form-control m-b" th:with="deptAll=${@deptService.getDeptAll()}" required>
                        <option value="">请选择</option>
                        <option th:each="dept : ${deptAll}" th:text="${dept.getShowName()}" th:value="${dept.getDeptId()}"  th:if="${dept.getStatus() != '1' && dept.getDelFlag() == '0' }"  th:hidden="${dept.getStatus() == '1' || dept.getDelFlag() != '0' }"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">入职岗位：</label>
                <div class="col-sm-8">
                    <select name="postId" class="form-control m-b" th:with="postAll=${@postService.getPostAll()}" required>
                        <option value="">请选择</option>
                        <option th:each="post : ${postAll}" th:text="${post.getPostName()}" th:value="${post.getPostId()}"  th:hidden="${post.getStatus() == '1'}"></option>
                    </select>
                </div>
            </div>


            <div class="form-group">
                <label class="col-sm-3 control-label is-required">手机号码：</label>
                <div class="col-sm-6">
                    <input id="phonenumber" name="phonenumber" placeholder="请输入手机号码" class="form-control" type="text" maxlength="11" required>
                </div>
                <div class="col-sm-2" id="phonenumberMark"><font color="red">格式不正确</font></div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label is-required">邮箱：</label>
                <div class="col-sm-8">
                    <input id="toOffEmail" name="toOffEmail" class="form-control email" type="text" maxlength="20" placeholder="请输入邮箱" required>
                </div>
            </div>


            <div class="form-group">
                <label class="col-sm-3 control-label is-required">入职日期：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        <input name="nonManagerDate" class="form-control" readonly="readonly" placeholder="yyyy-MM-dd" type="text" required>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label is-required">试用期限：</label>
                <div class="col-sm-8">
                    <input name="probationDate" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">offer附件：</label>
                <div class="col-sm-8">
                    <input name="adjunctFile" class="form-control" type="file" required>最大50M/1
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label  is-required">简历附件：</label>
                <div class="col-sm-8">
                    <input name="resumeAdjunctFile" class="form-control" type="file" required>最大50M/1
                    <!--<input name="resumeAdjunct" class="form-control" type="text">-->
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label is-required">薪酬级别审批：</label>
                <div class="col-sm-8">
                    <select name="salaryLevel" class="form-control m-b  select2-multiple" th:with="type=${@dict.getType('sys_salary_level_type')}" required>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>


            <div class="form-group">
                <label class="col-sm-3 control-label is-required">薪酬标准审批：</label>
                <div class="col-sm-6">
                    <textarea name="salaryStandard" id="salaryStandard"  class="form-control" required></textarea>
                </div>
                <div class="col-sm-2" id="salaryStandardMark"><font color="red">字数限制在300字以内</font></div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label  is-required">员工入职薪资告知单附件：</label>
                <div class="col-sm-8">
                    <input name="salaryAdjunctFile" class="form-control" type="file" required>最大50M/1
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label is-required">招聘员姓名：</label>
                <div class="col-sm-8">
                    <input name="recruiterName" class="form-control" maxlength="10" type="text" required>
                </div>
            </div>

        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: select2-js" />
    <th:block th:include="include :: datetimepicker-js" />
    <script type="text/javascript">
        var prefix = ctx + "hr/hrOff"
        $("#form-hrOff-add").validate({
            focusCleanup: true
        });

        $("input[name='nonManagerDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("#phonenumberMark").hide();
        $("#phonenumber").blur(function(){

            var str = $("#phonenumber").val();
            if (!(/^1[3456789]\d{9}$/.test(str)) ){
                // $("#phonenumber").val("");
                $("#phonenumberMark").show();
                // $.modal.alertWarning("字数限制在50字以内");
            }else {
                $("#phonenumberMark").hide();
            }
        });

        $("#salaryStandardMark").hide();
        $("#salaryStandard").keyup(function(){
            debugger
            var str = $("#salaryStandard").val();
            if (str.length > 300 ){
                $("#salaryStandard").val(str.substring(0,300));
                $("#salaryStandardMark").show();
                // $.modal.alertWarning("字数限制在50字以内");
            }else {
                $("#salaryStandardMark").hide();
            }
        });


        function submitHandler() {
            if ($.validate.form()) {

                var str = $("#phonenumber").val();
                if (!(/^1[3456789]\d{9}$/.test(str)) ){
                    // $("#phonenumber").val("");
                    $("#phonenumberMark").show();
                    $.modal.alertWarning("手机号码格式不正确");
                    return;
                }

                // $.operate.save(prefix + "/add", $('#form-hrOff-add').serialize());
                var form = document.getElementById('form-hrOff-add'),
                    formData = new FormData(form);
                // debugger
                $.ajax({
                    url: prefix + "/add",
                    type: "post",
                    data: formData,
                    processData: false,
                    contentType: false,
                    beforeSend: function () {
                        $.modal.loading("正在处理中，请稍后...");
                        $.modal.disable();
                    },
                    success: function(result) {
                        $.operate.successCallback(result);
                    }
                });
            }
        }
    </script>
</body>
</html>